<template>
	<view class="">
		<view class="openScreen" style="background-color: #d43428;width: 100vw; height: 100vh;" v-if="advertising">
			<button class="cu-btn round bg-blue" @click="jmp"
				style="position: fixed; background-color: transparent; color: #fff; border-radius: 40rpx;border: 1rpx dashed #ccc; z-index: 1; width: 150rpx; height: 64rpx; display: ; box-sizing: ; left: 580rpx; bottom: 100rpx;line-height: 64rpx; font-size: 26rpx;">跳过{{time}}</button>
			<image
			v-if="height <= 667"
				:src="openImage"
				mode="aspectFill"
				style="width: 100%;height:100vh;position:fixed" />
				<image
				v-if="height > 667"
					:src="openImage1"
					mode="aspectFill"
					style="width: 100%;height:100vh;position:fixed" />
		</view>
	</view>
</template>

<script>
	export default {
		data(){
			return{
				advertising: true,
				time: 3, //倒计时 秒
				//开屏广告
				x: '',
				openImage:this.$image_url+'/uploads/uniapp/image/open_screen.jpg'+'?' + Math.random() / 9999,
				openImage1:this.$image_url+'/uploads/uniapp/image/open_screen_second.jpg'+'?' + Math.random() / 9999,
				height:''
			}
		},
		onLoad(){

			// this.silentLogin()
			var _this = this
			_this.height = uni.getSystemInfoSync().windowHeight;
			wx.hideTabBar(); // 隐藏底部按钮
			_this.x = setInterval(function() {
				_this.time = _this.time - 1
				if (_this.time == 0)
					_this.jmp()
			}, 1000) //每秒执行一次
			// return
		},
		methods:{
			//  silentLogin() {
			// 	 let that = this
			// 	uni.login({
			// 		provider: 'weixin',
			// 		success: function(loginRes) {
			// 			console.log(loginRes);
			// 			that.$api.silentLogin({ code:loginRes.code }).then(function(res) {
			// 				if (res.code == 1) {

			// 					that.$u.vuex('vuex_token', res.data.user.token);

			// 					that.success(3);
			// 				} else {
			// 					that.$u.toast(res.msg);
			// 					setTimeout(() => {
			// 						uni.$u.route('/pages/index/index');
			// 					},1000)
			// 				}
			// 			});
			// 		},
			// 		fail(e) {
			// 			console.log(e);
			// 		}
			// 	});
			// },
			jmp() {
				// return
				var _this = this
				_this.advertising = false

				// uni.setStorageSync('storage_key', 'hello');
				uni.showTabBar({
					animation: true //动画效果
				});
				clearInterval(_this.x); //清除定时器
				uni.redirectTo({
					url:'/pages/index/index'
				})

			}, //跳过广告
		}
	}
</script>

<style>
</style>
